package com.lovejes.cuniao.util;

import com.lovejes.cuniao.conf.Constant;
import com.tencent.weibo.api.T_API;
import com.tencent.weibo.beans.OAuth;
import com.tencent.weibo.utils.Configuration;
import com.tencent.weibo.utils.OAuthClient;
import com.tencent.weibo.utils.WeiBoConst;

/**
 * @author hxj
 * 
 */
public class TencentOAuth {

	public static String request(String backurl) {
		OAuth oAuth = new OAuth(Constant.TENCENT_CONSUMER_KEY,
				Constant.TENCENT_CONSUMER_SECRET, backurl);
		OAuthClient authClient = new OAuthClient();
		try {
			oAuth = authClient.accessToken(oAuth);
			return oAuth.getOauth_token();
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	
	/**
	 * 
	 */
	public static void update(OAuth oAuth,String content) {
		T_API t = new T_API();
		try {
			t.add(oAuth, WeiBoConst.ResultType.ResultType_Json, content, Configuration.wifiIp);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
